package com.bbs.db.impl;

import com.bbs.db.iface.AdmininfoDao;
import com.bbs.db.pers.Admininfo;
import java.util.List;
import org.springframework.dao.DataAccessException;
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;

/**
 * @time Nov 12, 2009, 9:07:38 PM
 * @author fdcube
 */
public class AdmininfoImpl extends HibernateDaoSupport implements AdmininfoDao {

    public boolean AddAdmin(Admininfo value) {
        try {
            this.getHibernateTemplate().save(value);
            return true;
        } catch (DataAccessException dataAccessException) {
            logger.error(dataAccessException);
            return false;
        }
    }

    public boolean DeleteAdmin(Admininfo value) {
        try {
            this.getHibernateTemplate().delete(value);
            return true;
        } catch (DataAccessException dataAccessException) {
            logger.error(dataAccessException);
            return false;
        }
    }

    public List<Admininfo> FindAdmin(Admininfo value) {
        try {
            return this.getHibernateTemplate().findByNamedParam("FROM Admininfo AS a WHERE a.aname =:aname AND a.apwd =:apwd", new String[]{"aname", "apwd"}, new String[]{value.getAname(), value.getApwd()});
        } catch (DataAccessException dataAccessException) {
            logger.error(dataAccessException);
            return null;
        }
    }
}
